import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueDevTools from "vite-plugin-vue-devtools";
import VueSetupExtend from "vite-plugin-vue-setup-extend"; //vite-plugin-vue-setup-extend给组件添加name属性
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueDevTools(), VueSetupExtend()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  server: {
    // 禁用自动打开浏览器，避免Windows系统错误
    open: true,
    // 可选：指定主机地址
    host: true,
    // 配置代理解决跨域问题
    proxy: {
      "/api": {
        target: "https://api.uomg.com",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});
